package com.interview.ujiuye;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Demo6 {
    public static void main(String[] args) throws Exception {
        File file = new File("log.txt");//创建文件
        List<String> list = new ArrayList<>();//创建list集合：可变数组
        BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
        while (bufferedReader.ready()){
            String line = bufferedReader.readLine();//一次读取一行
            if(line != null && line.length() > 0){  //判断空行
                String[] data = line.split(" ");//使用空格分割
                list.add(data[3]);//添加到list集合
            }
        }
        String [] objects =  list.toArray(new String []{});//转成字符数组
        System.out.println(list.size());
        System.out.println(Arrays.toString(objects));
    }
}
